//
//  BaseViewController.m
//  Wangi
//
//  Created by ChuXiang on 15/11/23.
//  Copyright © 2015年 ChuXiang. All rights reserved.
//

#import "BaseViewController.h"
#import "WYKit.pch"
#import "BaseModel.h"
#import "URLManager.pch"
#import "NetWorkTaskHandle.h"
@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.barTintColor = [UIColor redColor];
    [self.navigationController.navigationBar setTitleTextAttributes:
     
     @{NSFontAttributeName:[UIFont systemFontOfSize:20],
       
       NSForegroundColorAttributeName:[UIColor whiteColor]}];
}

- (NSMutableArray *)getDataWithNumber:(NSString *)num withURL:(NSString *)url {
    NSMutableArray *data = [NSMutableArray arrayWithCapacity:0];
    // 老王方法
//    [SANetWorkingTask request:url parmater:nil block:^(id result) {
//        if (result) {
//            NSArray *array = result[num];
//            for (NSDictionary *dic in array) {
//                BaseModel *model = [[BaseModel alloc] initWithData:dic];
//                [data addObject:model];
//            }
//            NSLog(@"%@", data);
//        }
//    }];
    // 封装方法
    [NetWorkTaskHandle sendTask:url withResult:^(id result) {
        if (result) {
            NSArray *array = result[num];
            for (NSDictionary *dic in array) {
                BaseModel *model = [[BaseModel alloc] initWithData:dic];
                [data addObject:model];
            }
            dispatch_async(dispatch_get_main_queue(), ^{

            });
        }
    }];
    return data;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
